﻿<div style="width:100%;overflow:hidden;">
<div style="margin-left:1%;margin-top:5px;">
    <form method="get">
        <div style="float:left;">日期范围:&nbsp;&nbsp;</div>
        <div style="float:left;">
            <input id="start" class="liger-dateeditor" type="text" name="start" value="@DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd")" />
        </div>
        <div style="float:left;">~</div>
        <div style="float:left;"><input id="end" class="liger-dateeditor" type="text" name="end" value="@DateTime.Now.ToString("yyyy-MM-dd")" /></div>
        &nbsp;&nbsp;
        <input type="button" onclick="loadData();" value="查询" style="width:60px;"/>
    </form>    
</div>
<div id="grid" style="margin-left:1%;margin-top:10px;"></div>
</div>

<script type="text/javascript">
    Date.fromISO = function (s) {
        var day, tz,
        rx = /^(\d{4}\-\d\d\-\d\d([tT ][\d:\.]*)?)([zZ]|([+\-])(\d\d):(\d\d))?$/,
        p = rx.exec(s) || [];
        if (p[1]) {
            day = p[1].split(/\D/);
            for (var i = 0, L = day.length; i < L; i++) {
                day[i] = parseInt(day[i], 10) || 0;
            };
            day[1] -= 1;
            day = new Date(Date.UTC.apply(Date, day));
            if (!day.getDate()) return NaN;
            if (p[5]) {
                tz = (parseInt(p[5], 10) * 60);
                if (p[6]) tz += parseInt(p[6], 10);
                if (p[4] == '+') tz *= -1;
                if (tz) day.setUTCMinutes(day.getUTCMinutes() + tz);
            }
            return day;
        }
        return NaN;
    }

    function loadData() {
        var grid = liger.get('grid');
        grid.reload();
        //grid.loadServerData({
        //    start: $('#start').val(),
        //    end: $('#end').val()
        //});
    }

    var _window = {};

    _window.options = {
        /* grid */
        columns: [
            {
                name: 'flowname', display: '审批流程名称', width: 200,
                render: function (r) {
                    return '<a href="/Item/Info?id=' + r.id + '" target="_self">' + r.flowname + '</a>';
                }
            }
            , { name: 'username', display: '申请人', width: 120 }
            , { name: 'dept', display: '申请人部门', width: 120 }
            , {
                name: 'creationtime', display: '申请时间', width: 120, render: function (r) {
                    var t = new Date(r.creationtime);
                    if (!t || isNaN(t))
                        t = Date.fromISO(r.creationtime);

                    return t.toLocaleDateString();
                }
            }
        ],
        toolbar: { items: [] }
    };

    _window.control = {
        grid: null
    };

    _window.getparams = function () {
        return {
            start: $('#start').val(),
            end: $('#end').val()
        };
    }

    _window.grid = function () {
        _window.control.grid = $('#grid').ligerGrid({
            columns: _window.options.columns,
            resizable: false,
            frozen: false,
            height: '98%',
            width: '98%',
            rownumbers: true,
            url: '/Reception/Query',
            parms: _window.getparams
        });
    }

    _window.init = function () {
        _window.grid();
    }

    /* ---------------------------------------------------------------------   */


    /* ---------------------------------------------------------------------   */
    $(document).ready(function () {
        _window.init();
    });
</script>